﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows.Forms;
using PolePosition.v3.EntityLibrary;

namespace PolePosition.v3.Desktop
{
    public class ComboOptions
    {
        public static BindingList<Common.BindingLists.ListItem> PoleYears
        {
            get
            {
                BindingList<Common.BindingLists.ListItem> _Values = new BindingList<Common.BindingLists.ListItem>();
                for (int i = 1944; i <= DateTime.Now.Year; i++)
                {
                    _Values.Add(new Common.BindingLists.ListItem() { Text = i.ToString(), Value = i });
                }
                return _Values;
            }
        }

        public static BindingList<Common.BindingLists.ListItem> YesNoForBoolean
        {
            get
            {
                BindingList<Common.BindingLists.ListItem> _List;
                _List = new BindingList<PolePosition.v3.Common.BindingLists.ListItem>();
                _List.Add(new Common.BindingLists.ListItem());
                _List.Add(new Common.BindingLists.ListItem() { Text = "Yes", Value = true, Tag = null });
                _List.Add(new Common.BindingLists.ListItem() { Text = "No", Value = false, Tag = null });

                return _List;
            }
        }

        public static void Kv(System.Windows.Forms.ComboBox comboBox)
        {
            comboBox.DisplayMember = "Text";
            comboBox.ValueMember = "Value";

            BindingList<Common.BindingLists.ListItem> _List;
            _List = Common.BindingLists.GetList(Program.LookupTableData.VendorVisitType,
                EntityLibrary.VendorVisitTypeEnumerations.Columns.Name.ToString(),
                EntityLibrary.VendorVisitTypeEnumerations.Columns.Vendor_Visit_TypeId.ToString(), true);
            comboBox.DataSource = _List;
        }

        public static void PoleSpecies(System.Windows.Forms.ComboBox comboBox)
        {
            comboBox.DisplayMember = "Text";
            comboBox.ValueMember = "Value";

            BindingList<Common.BindingLists.ListItem> _List;
            _List = Common.BindingLists.GetList(Program.LookupTableData.XMissionStructuresPoleSpecies,
                EntityLibrary.XMissionStructuresPoleSpeciesEnumerations.Columns.Name.ToString(),
                EntityLibrary.XMissionStructuresPoleSpeciesEnumerations.Columns.XMissionStructures_PoleSpeciesId.ToString(), true);
            comboBox.DataSource = _List;
        }

        public static void PoleXmissionClass(System.Windows.Forms.ComboBox comboBox)
        {
            comboBox.DisplayMember = "Text";
            comboBox.ValueMember = "Value";

            BindingList<Common.BindingLists.ListItem> _List;
            _List = Common.BindingLists.GetList(Program.LookupTableData.XMissionStructuresPoleClasses,
                EntityLibrary.XMissionStructuresPoleClassesEnumerations.Columns.Name.ToString(),
                EntityLibrary.XMissionStructuresPoleClassesEnumerations.Columns.XMissionStructures_PoleClassId.ToString(), true);
            comboBox.DataSource = _List;
        }

        public static void PoleDistributionClass(System.Windows.Forms.ComboBox comboBox)
        {
            comboBox.DisplayMember = "Text";
            comboBox.ValueMember = "Value";

            BindingList<Common.BindingLists.ListItem> _List;
            _List = Common.BindingLists.GetList(Program.LookupTableData.DistributionClasses,
                EntityLibrary.DistributionClassesEnumerations.Columns.Name.ToString(),
                EntityLibrary.DistributionClassesEnumerations.Columns.ClassId.ToString(), true);
            comboBox.DataSource = _List;
        }

        public static void PoleDistributionLengths(System.Windows.Forms.ComboBox comboBox)
        {
            comboBox.DisplayMember = "Text";
            comboBox.ValueMember = "Value";

            BindingList<Common.BindingLists.ListItem> _List;
            _List = Common.BindingLists.GetList(Program.LookupTableData.DistributionLengths,
                EntityLibrary.DistributionLengthEnumerations.Columns.Name.ToString(),
                EntityLibrary.DistributionLengthEnumerations.Columns.LengthId.ToString(), true);
            comboBox.DataSource = _List;
        }

        public static void PoleTreatment(System.Windows.Forms.ComboBox comboBox)
        {
            comboBox.DisplayMember = "Text";
            comboBox.ValueMember = "Value";

            BindingList<Common.BindingLists.ListItem> _List;
            _List = Common.BindingLists.GetList(Program.LookupTableData.XMissionStructuresPoleTreatments,
                EntityLibrary.XMissionStructuresPoleTreatmentEnumerations.Columns.Name.ToString(),
                EntityLibrary.XMissionStructuresPoleTreatmentEnumerations.Columns.XMissionStructures_PoleTreatmentId.ToString(), true);
            comboBox.DataSource = _List;
        }

        public static void PoleXmissionTopTypes(System.Windows.Forms.ComboBox comboBox)
        {
            comboBox.DisplayMember = "Text";
            comboBox.ValueMember = "Value";

            BindingList<Common.BindingLists.ListItem> _List;
            _List = Common.BindingLists.GetList(Program.LookupTableData.XMissionStructuresPoleTopTypes,
                EntityLibrary.XMissionStructuresPoleTopTypeEnumerations.Columns.Name.ToString(),
                EntityLibrary.XMissionStructuresPoleTopTypeEnumerations.Columns.XMissionStructures_PoleTopTypeId.ToString(), true);
            comboBox.DataSource = _List;
        }

        public static void Maps(System.Windows.Forms.ComboBox comboBox)
        {
            comboBox.DisplayMember = "Text";
            comboBox.ValueMember = "Value";

            BindingList<Common.BindingLists.ListItem> _List;
            _List = Common.BindingLists.GetList(Program.LoginResult.Polygons,
                EntityLibrary.UtilityPolygonEnumerations.Columns.Name.ToString(),
                EntityLibrary.UtilityPolygonEnumerations.Columns.Utility_PolygonId.ToString(), true);
            comboBox.DataSource = _List;
        }

        public static void InspectionResults(System.Windows.Forms.ComboBox comboBox)
        {
            comboBox.DisplayMember = "Text";
            comboBox.ValueMember = "Value";

            BindingList<Common.BindingLists.ListItem> _List;
            _List = Common.BindingLists.GetList(Program.LookupTableData.VendorInspVisitXmissionStructuresResultTypes,
                EntityLibrary.VendorInspVisitXmissionStructuresResultTypeEnumerations.Columns.Name.ToString(),
                EntityLibrary.VendorInspVisitXmissionStructuresResultTypeEnumerations.Columns.Vendor_InspVisit_XmissionStructures_ResultTypeId.ToString(), true);
            comboBox.DataSource = _List;
        }

        public static void InspectionTypes(System.Windows.Forms.ComboBox comboBox)
        {
            comboBox.DisplayMember = "Text";
            comboBox.ValueMember = "Value";

            BindingList<Common.BindingLists.ListItem> _List;
            _List = Common.BindingLists.GetList(Program.LookupTableData.VendorInspVisitXmissionStructuresInspectionType,
                EntityLibrary.VendorInspVisitXmissionStructuresInspectionTypeEnumerations.Columns.Name.ToString(),
                EntityLibrary.VendorInspVisitXmissionStructuresInspectionTypeEnumerations.Columns.Vendor_InspVisit_XmissionStructures_Inspection_TypeId.ToString(), true);
            comboBox.DataSource = _List;
        }

        public static void RemedyStatus(System.Windows.Forms.ComboBox comboBox)
        {
            comboBox.DisplayMember = "Text";
            comboBox.ValueMember = "Value";

            BindingList<Common.BindingLists.ListItem> _List;
            _List = Common.BindingLists.GetList(Program.LookupTableData.RemedyStatus,
                EntityLibrary.RemedyStatusEnumerations.Columns.Name.ToString(),
                EntityLibrary.RemedyStatusEnumerations.Columns.RemedyStatusId.ToString(), true);
            comboBox.DataSource = _List;
        
        }

        public static void RemedyStatus(System.Windows.Forms.DataGridViewComboBoxColumn comboBox)
        {
            comboBox.DisplayMember = "Text";
            comboBox.ValueMember = "Value";

            BindingList<Common.BindingLists.ListItem> _List;
            _List = Common.BindingLists.GetList(Program.LookupTableData.RemedyStatus,
                EntityLibrary.RemedyStatusEnumerations.Columns.Name.ToString(),
                EntityLibrary.RemedyStatusEnumerations.Columns.RemedyStatusId.ToString(), true);
            comboBox.DataSource = _List;
        }

        public static void DistributionLookUp(System.Windows.Forms.ComboBox comboBox, VendorDistributionLookupsType type)
        {
            comboBox.DisplayMember = "Text";
            comboBox.ValueMember = "Value";
            
            BindingList<Common.BindingLists.ListItem> _List;
            _List = Common.BindingLists.GetList(Program.LookupTableData.VendorDistributionLookups.Where(x => x.LookUpType == (int)type).ToList(),
                VendorDistributionLookupsEnumerations.Columns.LookUpText.ToString(),
                VendorDistributionLookupsEnumerations.Columns.Vendor_Distribution_LookupId.ToString(), true);
            
            comboBox.DataSource = _List;
        }

        public static void Range(ComboBox comboBox, int from, int to)
        {
            for (int i = from; i <= to; i++)
                comboBox.Items.Add(new Common.BindingLists.ListItem() { Text = i.ToString(), Value = i });
        }
    }
}
